// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        icon1: {
            default: null,
            type: cc.SpriteFrame
        },

        icon2: {
            default: null,
            type: cc.SpriteFrame
        },

        icon3: {
            default: null,
            type: cc.SpriteFrame
        },

        icon4: {
            default: null,
            type: cc.SpriteFrame
        },

        icon5: {
            default: null,
            type: cc.SpriteFrame
        },

        icon6: {
            default: null,
            type: cc.SpriteFrame
        },

        icon7: {
            default: null,
            type: cc.SpriteFrame
        },

        icon8: {
            default: null,
            type: cc.SpriteFrame
        },

        icon9: {
            default: null,
            type: cc.SpriteFrame
        },

        icon10: {
            default: null,
            type: cc.SpriteFrame
        },

        icon11: {
            default: null,
            type: cc.SpriteFrame
        },

        icon12: {
            default: null,
            type: cc.SpriteFrame
        },

        icon13: {
            default: null,
            type: cc.SpriteFrame
        },

        icon14: {
            default: null,
            type: cc.SpriteFrame
        },

        icon15: {
            default: null,
            type: cc.SpriteFrame
        },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    setIcon : function(iconIndex)
    {
        var iconNode = this.node.getChildByName('iconSprite');
        var icons = [this.icon1, this.icon2, this.icon3, this.icon4, this.icon5,
        this.icon6, this.icon7, this.icon8, this.icon9, this.icon10,
        this.icon11, this.icon12, this.icon13, this.icon14, this.icon15];

        // iconNode.getComponent(cc.Sprite).spriteFrame = icons[iconIndex];

        var url = "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTLicEOk3D36qntUBRo4yR9hicica2mBlhnibWE0rU798Drib5zvqyhyxTQ0bIBPWFOgM4LMtOL6VmAYWHQ/132?aa=aa.jpg";
        cc.loader.load(url, function (err, texture) {
         var frame = new cc.SpriteFrame(texture);
         var iconSprite = iconNode.getComponent(cc.Sprite);
         iconSprite.spriteFrame = frame;
        });
    },

    // start () {

    // },

    // update (dt) {},
});
